# 定义源文件和目标文件
COMMON_DIR = ../../common
COMMON_SRCS = $(COMMON_DIR)/etcd.cpp $(COMMON_DIR)/log.cpp $(COMMON_DIR)/channel.cpp main.pb.cc
COMMON_OBJS = $(COMMON_SRCS:.cpp=.o)

# 定义编译选项
CXXFLAGS = -std=c++17 -I$(COMMON_DIR) -Wall -g

LDFLAGS = -lspdlog -lfmt -letcd-cpp-api -lcpprest -lgflags -lbrpc -lprotobuf -lssl -lcrypto -lleveldb 

all: server client

server: server.cpp $(COMMON_OBJS)
	g++ -o $@ $^ $(CXXFLAGS) $(LDFLAGS)

client: client.cpp $(COMMON_OBJS)
	g++ -o $@ $^ $(CXXFLAGS) $(LDFLAGS)

# 编译 common 目录下的源文件
$(COMMON_DIR)/%.o: $(COMMON_DIR)/%.cpp
	g++ -c $< -o $@ $(CXXFLAGS)

.PHONY: clean
clean:
	rm -rf server client $(COMMON_OBJS)